package site.yunnong.atvris.portal.spider.baidu;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.HtmlField;
import com.geccocrawler.gecco.annotation.RequestParameter;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.spider.HtmlBean;
import lombok.Data;

import java.util.List;

/**
 * @author zjh
 * @date 2021/8/31 10:57
 */
@Data
@Gecco(matchUrl = "https://www.baidu.com/sf/vsearch?pd={type}&tn=vsearch&lid={lid}&ie=utf-8&wd={wd}&rsv_spt=7&rsv_bp=1&f=8&oq={oq}&rsv_pq=ffb4b36e0001af01&rsv_t={rsv_t}&async=1&pn={pn}", pipelines = "baiduPagePipeline")
public class BaiduPage implements HtmlBean {
    
    @RequestParameter
    private String type;
    
    @RequestParameter
    private String lid;
    
    @RequestParameter
    private String wd;

    @RequestParameter
    private String oq;

    @RequestParameter
    private String rsv_pq;
    @RequestParameter
    private String rsv_t;
    @RequestParameter
    private String async;
    // count
    @RequestParameter
    private String pn;
    
    @HtmlField(cssPath = ".video_list")
    private List<BaiduVideo> baiduVideoList;

    public static void main(String[] args) {
        int count = 10;
//        String url = "https://www.baidu.com";
        String url = "https://www.baidu.com/sf/vsearch?pd=video&tn=vsearch&lid=ffb4b36e0001af01&ie=utf-8&wd=%E6%B0%B4%E4%BA%A7%E5%85%BB%E6%AE%96&rsv_spt=7&rsv_bp=1&f=8&oq=%E6%B0%B4%E4%BA%A7%E5%85%BB%E6%AE%96&rsv_pq=ffb4b36e0001af01&rsv_t=18e9jtFwautlgnmQ3ZikTtksYo1WzQTOtkgkowxSx9n7mqIW2ZRS4lKyZyo&async=1&pn=" + count;
        HttpGetRequest start = new HttpGetRequest(url);
        GeccoEngine.create()
                .classpath("site.yunnong.atvris.portal.spider.baidu")
                .seed(start)
                .thread(1)
                .interval(2000)
                .start();
    }
}
